package File;

import java.io.File;

public class DeleteFileDirDemo {
    public static void main(String[] args) {
        //File f = new File("./test/txt"); //文件
        //File f = new File("./demo"); //删除demo
        //File f = new File("./a/b/c"); //删除a下的b下的c
        File dir = new File(".");// "."表示当前目录

        if (dir.isDirectory()){
            File[] subs = dir.listFiles();
            System.out.println("当前项目目录下共有"+subs.length+"个子项");
            for (File sub:subs){
                System.out.println(sub);//输出每个子项的名称
            }
        }



        /*
        File f=new File("./a");
        if (f.exists()){
            f.delete();
            System.out.println("该文件或目录已删除");
        }else {
            System.out.println("该目录或文件不存在");
        }
         */

    }
}
